<?php
/*
Copyright (C) 2009 de Flotte Maxence

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
?>
<?php
class ZzLabel {
	
	/**
	* Get the current label id
	*/
	static function getId() {
		$_label = explode('-',$_GET['label']);
		return $_label[0];
	}
	/**
	* Get the parent lid
	* @param string|int $lvl The level (0 = current, 1 or nothing or last = parent, 2 = parent of the parent, ...)
	*/
	static function getParentId($lvl = null) {
		$_label = explode('-',$_GET['label']);

		if($lvl == null or $lvl == 'last')
			return @$_label[1];
		elseif(is_numeric($lvl))
			return @$_label[$lvl];
		else
			return 'ERROR_LVL';
	}
	/**
	* Remove cache files of the current label
	* Dont use this function
	*/
	static function up() {
		$label = ZzGetLabel();
		include_once './ZzL/manageLabel.php';
		ZzUpdateLabel($label,null,null,null);
	}
	/**
	* Remove cache files of the parent label
	* Dont use this function
	*/
	static function upLast() {
		$label = ZzLabel::getParentId();
		if($label != null) {
			include_once './ZzL/manageLabel.php';
			ZzUpdateLabel($label,null,null,null);
		}
	}
	/**
	* Get the label owner
	* @return int
	*/
	static function getUser() {
		return $GLOBALS['label_user'];
	}
	/**
	* Get the label group owner
	* @return int
	*/
	static function getGroup() {
		return $GLOBALS['label_group'];
	}
}
?>